<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
<link rel="stylesheet"
	href="../statics/bootstrap-3.3.0/css/bootstrap.css"/>"
<link rel="stylesheet" href="../statics/css/style.css"/>"
</head>
<body
	style="background-image: url(../statics/image/background/loginbackground.jpg); background-size: cover">
	<div style="margin: 20px auto">
		<div style="margin: 100px auto; margin-bottom: 40px" align="center">
			<h1 style="font-size: 60px">欢迎登录阳光校园二手交易平台</h1>
		</div>
	</div>
	<div class="container" style="position: relative; margin: 80px auto;">
		<div class="col-md-6 login-back"
			style="position: absolute; left: 50%; transform: translateX(-50%);">
			<input id="preURL" name="preURL" value="preURL"
				style="display: none">
			<div class="form-group">
				<label for="email">邮箱</label>
				<input class="form-control" type="text" id="email" placeholder="请输入用户名" required>
			</div>
			<div class="form-group">
				<label for="password">密码</label>
				<input class="form-control" type="password" id="password" required placeholder="请输入密码">
			</div>
			<form action="/loginn" method="post">
				<div id="flushimg">
					<label for="tryCode">验证码</label>
					<input id="tryCode" type="text" name="tryCode" class="form-control" required placeholder="-----请输入验证码-----" />
					<br>
					<img alt="验证码" onclick="this.src='/defaultKaptcha?d=' + new Date()*1" src="/defaultKaptcha" />
					<a>看不清？点击图片刷新一下</a>

				</div>
			</form>
			<br>
			<button style="margin-left: 10px; width: 45%" type="submit" class="btn btn-primary" id="login">登录</button>
			<a style="margin-left: 20px; width: 45%" class="btn btn-primary"
				href="/home/register.html">注册</a>
			<a href="../admin/adminLogin.html">管理员登录</a>
			<a style="float: right" href="/home/homeGoods.html">返回首页</a>
		</div>
	</div>
	<script src="../statics/jquery-1.12.4/jquery-1.12.4.js"/></script>
	<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
	<script src="../statics/bootstrap-3.3.0/js/bootstrap.js"></script>
</body>
<script type="text/javascript">
	$('#login').click(function (){
		var UserEmail = $("#email").val();  //登录昵称
		var password = $("#password").val();  //用户密码
		var tryCode = $("#tryCode").val();
		var inputData = {
			"inputEmail": UserEmail,
			"inputPassword":password,
			"tryCode":tryCode,
		};
		$.ajax({
			url: "/user/login",
			type: "POST",
			dataType:"json",
			contentType: "application/json;charset=utf-8",
			data:JSON.stringify(inputData),
			success:function (data) {
						if (data.code === 20000) {
							// window.location.href = "http://localhost:9000/user/userEdit.html";
							window.location.href = "homeGoods.html";
						}
						else{
							Swal.fire("提示", data.message, "error");
						}
					}
				});
			});
</script>
</html>